import { Service } from "~/core/service";
import { NetService } from "~/util/net.service";
import { Inject, Debounce } from "~/core/decorator";
import { serviceManage } from "~/config/server";

export class TaskService extends Service {

    @Inject(NetService)
    private netService: NetService;

    /**
     * 分页查询定时任务
     * @param page 
     */
    findTaskByPage(page) {
        return this.netService.send({
            server: serviceManage.taskController.findTaskByPage,
            page
        })
    }

    /**
   * 修改任务信息
   */
  updateJob(data: any) {
    return this.netService.send({
      server: serviceManage.taskController.updateJob,
      data,
    })
  }

  /**
   * 暂停任务
   */
  pauseJob(data: any) {
    return this.netService.send({
      server: serviceManage.taskController.pauseJob,
      data,
    })
  }

  /**
   * 恢复任务
   */
  resumeJob(data: any) {
    return this.netService.send({
      server: serviceManage.taskController.resumeJob,
      data,
    })
  }

  /**
   * 删除任务
   */
  deleteJob(data: any) {
    return this.netService.send({
      server: serviceManage.taskController.deleteJob,
      data,
    })
  }

  /**
   * 立即执行
   */
  runJob(data: any) {
    return this.netService.send({
      server: serviceManage.taskController.runJob,
      data,
    })
  }

  /**
   * 获取任务触发器列表
   */
  getAllTriggerOfJob(data: any) {
    return this.netService.send({
      server: serviceManage.taskController.getAllTriggerOfJob,
      data,
    })
  }

  /**
   * 添加触发器
   */
  addTrigger(data: any) {
    return this.netService.send({
      server: serviceManage.taskController.addTrigger,
      data,
    })
  }

  /**
   * 修改触发器
   */
  deleteTrigger(data: any) {
    return this.netService.send({
      server: serviceManage.taskController.deleteTrigger,
      data,
    })
  }

  /**
   * 暂停触发器
   */
  pauseTrigger(data: any) {
    return this.netService.send({
      server: serviceManage.taskController.pauseTrigger,
      data,
    })
  }

  /**
   * 恢复触发器
   */
  resumeTrigger(data: any) {
    return this.netService.send({
      server: serviceManage.taskController.resumeTrigger,
      data,
    })
  }
}